<?php
class Region
{
    public function getProvinceId($name)
    {
        global $DBobject;
        $sql = "SELECT * FROM tbl_region WHERE region_name = :region_name AND region_id mod 10000 = 0";
        $res = $DBobject->wrappedSql($sql, [':region_name' => $name]);

        return isset($res[0]['region_description']) ? $res[0]['region_description'] : null;
    }

    public function getCityId($name)
    {
        global $DBobject;
        $sql = "SELECT * FROM tbl_region WHERE region_name = :region_name AND region_id mod 10000 > 0 AND region_id mod 100 = 0";
        $res = $DBobject->wrappedSql($sql, [':region_name' => $name]);

        return isset($res[0]['region_description']) ? $res[0]['region_description'] : null;
    }

    public function getCountyId($name)
    {
        global $DBobject;
        $sql = "SELECT * FROM tbl_region WHERE region_name = :region_name AND region_id mod 100 > 0";
        $res = $DBobject->wrappedSql($sql, [':region_name' => $name]);

        return isset($res[0]['region_description']) ? $res[0]['region_description'] : null;
    }
}
